This program will hopefully generate prime numbers.

Define a function that tests if a number wholly divides another number.
#+BEGIN_SRC emacs-lisp
  (defun pr/whole-remainder (x y)
    "This will tell you if y evenly divides x"
    (if  (eq 0 (% x y))
        t nil))
#+END_SRC

#+RESULTS:
: pr/whole-remainder

This function recursively tests if a number is prime.
#+BEGIN_SRC emacs-lisp
  (defun pr/is-prime (x y)
    "return t if x is prime"
    (cond
     ;; if y == 1, then x is prime
     ((when (eq y 1)
        t))

     ;; make sure that y <= (/ x 2)
     ((when (> y
               (/ x 2))
        (pr/is-prime x (+ 1 (/ y 2)))))

     ;; if y evenly divides x, then x is NOT prime
     ((eq t (pr/whole-remainder x y))
      nil)

     ;; if y does not evenly divide x, then does y-1 divide x?
     ((pr/is-prime  x (- y 1)))))
#+END_SRC

#+RESULTS:
: pr/is-prime


#+BEGIN_SRC emacs-lisp
(provide 'prime-number-generator)
#+END_SRC
